package itheima.com.MyTree;

public class Students implements Comparable<Students> {
    private String name;
    private int age;

    @Override
    public String toString() {
        return "Students{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public Students(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public Students() {
    }

    @Override
    public int compareTo(Students o) {
        int result = this.age - o.age;
         result = result == 0 ? this.name.compareTo(o.name) : result;
        return result;
    }
}
